#!/bin/bash
if [[ $# -ne 1 ]]; then
    echo "The format is as follows:"
    echo "bash bowtie2-2.4.5.sh installpath"
    echo ":param installpath: 应用安装绝对路径"
    exit 1
fi

[[ ! "$1" =~ ^/.* || "$1" = "/" ]] &&  echo "请输入正确的安装路径" && exit 1

installpath=$1
[[ "$installpath" =~ .*/$ ]] && installpath=${installpath%/*}
set -e
yum install -y wget tar environment-modules

wget https://github.com/BenLangmead/bowtie2/releases/download/v2.4.5/bowtie2-2.4.5-linux-aarch64.zip -P $installpath
cd $installpath
unzip bowtie2-2.4.5-linux-aarch64.zip  && rm -rf $installpath/bowtie2-2.4.5-linux-aarch64.zip
mv bowtie2-2.4.5-linux-aarch64 bowtie2-2.4.5
cat>"$installpath/bowtie2-2.4.5/bowtie2_modulefiles"<<EOF
#%Module1.0
conflict
variable modfile [file normalize [info script]]
proc getModulefileDir {} {
    variable modfile
    set modfile_path [file dirname \$modfile]
    return \$modfile_path
}
set pwd [getModulefileDir]
set bowtie2 \$pwd
setenv bowtie2 \$bowtie2
prepend-path PATH \$bowtie2
EOF
echo $installpath


